#!/bin/bash
. /var/www/sandbox/dealscombined.co.uk/scripts/set-env.sh

cd $FEED_DIR

#Downloding Feeds
wget "$KGB_LINK" -O $FEED_DIR/kgb.zip
wget "$WOWCHER_LINK" -O $FEED_DIR/wowcher.zip
wget "$LIVSOC_LINK" -O $FEED_DIR/livingSocial.zip



#Inflating and Renaming Feed Files
unzip kgb.zip; cp datafeed_169191.xml kgb.xml; rm kgb.zip; rm datafeed_169191.xml
unzip wowcher.zip; cp datafeed_169191.xml wowcher.xml; rm wowcher.zip; rm datafeed_169191.xml
unzip livingSocial.zip; cp datafeed_169191.xml livingSocial.xml; rm livingSocial.zip; rm datafeed_169191.xml


#Start DB Import
echo "Processing feeds to populate DB";
cd $RUN_DIR
php runner.php > run.log 2> run.err

#Map Categories
echo "Mapping Categories"
./applyMappings.sh

#Manipulate data
echo "Running populator"
php populator.php > populator.log 2> populate.err

